var App = ( function( $ ) {
	var _jQuery = $();

	return {

		init: function( callback ) {


			callback && callback();
		},

		drawPlugin: function( name, el, config ) {

		},

		drawSpinbox: function( el, config ) {

		    var defaults =  {
		        value: 1,
		        min: 1,
		        max: 999,
		        hold: false
	      	};
			config = $.extend( true, defaults, config || {} );
			if( _jQuery.spinbox ) {
				$( el ).spinbox( config );
			}

		},

		drawChosen: function( el, config ) {

			var defaults = {};
			config = $.extend( true, defaults, config || {} );
			if( _jQuery.chosen ) {
				$( el ).chosen( config );
			}
		}

	};

} )( jQuery );

$( function(){

	App.drawChosen( ".chosen-el" );

	App.drawSpinbox( ".spinbox" );

	var leaderinfoEl = $( "#leaderinfo" );

	$('#myTabs a').on( "shown.bs.tab", function( e ) {

		var type = $( this ).data( "type" );
		leaderinfoEl.toggle( !type );

	} );

	var snCount = 0;

	$( "#devieceCnt" ).on( "changed.fu.spinbox", function( value, el ) {
		/*var count = value;
		var snTr = $("#snTb tbody tr"),
			currCount = snTr.length;
		if( currCount < snCount ) {

		}
		console.log( currCount );*/
	} );

	var backDateEl = $("#backDate");
	var backDateMoreEl = $("#backDateMore");
	$('.i-checks').iCheck( {
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
    } ).on( 'ifChecked', function( e ){
		var type = $(this).data("type");
		backDateEl.toggle( type );
		backDateMoreEl.toggle( !type );
		
	} );

} );